package com.solidumgame.ninja
{
	import Box2D.Dynamics.Joints.b2Joint;
	import Box2D.Dynamics.b2Body;
	
	import com.greensock.TweenMax;
	import com.pblabs.box2D.Box2DDebugComponent;
	import com.pblabs.box2D.Box2DManagerComponent;
	import com.pblabs.engine.PBE;
	import com.pblabs.engine.debug.Logger;
	import com.pblabs.engine.entity.IEntity;
	import com.pblabs.rendering2D.ui.SceneView;
	import com.solidumgame.ninja.knife.Knife;
	
	import flash.events.EventDispatcher;
	import flash.geom.Point;
	
	public class Match extends EventDispatcher
	{
		protected var knife:Knife;
		protected var box2DManager:IEntity;
		protected var box2DDebugger:IEntity;
		protected static var sceneView:SceneView;
		//protected var currentPot:Pot;
		//protected var
		
		public function Match():void
		{
			createScene();
			createBox2DManager();
			createBox2DDebugger();			
			initSingleElements();
			newMatch();
		}
		
		protected function initSingleElements():void{
			knife = new Knife();
		}
		
		private function newMatch():void{
			//currentPot = new Pot();
			//currentPot.addEventListener(PotGenericEvent.POT_ENTER_EVENT, PotInPosition);
			
		}
		
		
		
		private function createBox2DDebugger():void {
			// Create debugger component.
			var comp:Box2DDebugComponent = new Box2DDebugComponent();
			comp.spatialManager = PBE.lookupEntity("SpatialManager").lookupComponentByName("Manager") as Box2DManagerComponent;
			comp.scene = PBE.scene;
			
			// Allocate new entity and add components.
			box2DDebugger = PBE.allocateEntity();
			box2DDebugger.addComponent(comp, "Debug");
			box2DDebugger.initialize("SpatialDebugger");
		}
		
		
		
		private function createScene():void {
			if(sceneView==null){
				sceneView = new SceneView();
				sceneView.width = 640;
				sceneView.height = 480;
				PBE.initializeScene(sceneView);
			}
		}
		
		private function createBox2DManager():void {
			
			var comp:Box2DManagerComponent = new Box2DManagerComponent();
			
			box2DManager = PBE.allocateEntity();
			box2DManager.addComponent(comp, "Manager");
			box2DManager.initialize("SpatialManager");
		}
		
	}
}

